import { request } from "@/utils/service"
import type * as Contacts from "./types"

/** 增 */
export function createContactsApi(data: Contacts.CreateOrUpdateContactsRequestData) {
  return request({
    url: "contacts",
    method: "post",
    data
  })
}

/** 删 */
export function deleteContactsApi(id: string) {
  return request({
    url: `contacts/${id}`,
    method: "delete"
  })
}

/** 改 */
export function updateContactsApi(data: Contacts.CreateOrUpdateContactsRequestData) {
  return request({
    url: "contacts/" + data.id,
    method: "put",
    data
  })
}

/** 查 */
export function getContactsApi(params: Contacts.GetContactsRequestData) {
  return request<Contacts.GetContactsResponseData>({
    url: "contacts",
    method: "get",
    params
  })
}

/** 查详情 */
export function getContactsDetailApi(id: string) {
  return request<Contacts.GetNewResponeseDetailData>({
    url: `contacts/${id}`,
    method: "get"
  })
}
